package com.ynet.middleground.user.service.impl;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

import com.ynet.middleground.user.bean.SupplierInformationReq;
import com.ynet.middleground.user.common.ErrorMessageConstant;
import com.ynet.middleground.user.dto.CustomerInformationDto;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.google.common.base.Throwables;
import com.ynet.core.common.ServiceResult;
import com.ynet.core.exception.BusinessException;
import com.ynet.core.log.IfpLogger;
import com.ynet.middleground.user.bean.CustomerInformationReq;
import com.ynet.middleground.user.dto.MasterDataSystemDto;
import com.ynet.middleground.user.model.MasterDataSystemModel;
import com.ynet.middleground.user.service.MasterDataSystemService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

/**
 * @program: 2019-10-12_userCenter
 * @description:
 * @author: DaiGaoLe
 * @create: 2019-11-10 17:28
 **/
@Api(value = "主数据系统", tags = {"主数据系统服务"})
@Produces({MediaType.APPLICATION_JSON + "; " + "charset=UTF-8"})
@Path("master")
@Service(timeout = 6000, version = "0.0.1")
public class MasterDataSystemServiceImpl implements MasterDataSystemService, GenericService {

    @Autowired
    MasterDataSystemModel masterDataSystemModel;

    @POST
    @Path("customer")
    @ApiOperation(value = "获取主系统客户信息", notes = "获取主系统客户信息,日期格式的传YYYY-MM-DD HH24:MI:SS这种格式，symbol中等值匹配用\"=\"，模糊匹配用\"like\"，还可以传\">\", \"<\", \">=\", \"<=\"用于比较,若不需分页则pageSize和pageNum同时传0，查询时使用最少一个查询条件")
    @Override
    public ServiceResult<List<CustomerInformationDto>> getMasterDataCustomer(CustomerInformationReq requestObject) {
        ServiceResult<List<CustomerInformationDto>> serviceResult = new ServiceResult<>();
        List<CustomerInformationDto> masterDataSystemDtos = null;
        try {
            masterDataSystemDtos = masterDataSystemModel.getMasterDataCustomer(requestObject);
        } catch (BusinessException be) {
            serviceResult.setError(be.getCode(), be.getMessage());
            return serviceResult;
        } catch (Exception e) {
            // 获取当前方法名
            IfpLogger.error(Thread.currentThread().getStackTrace()[1].getMethodName(), "case: {}",
                    Throwables.getStackTraceAsString(e));
            serviceResult.setError(ErrorMessageConstant.ECUC0000_CODE, ErrorMessageConstant.ECUC0000_MESSAGE);
            return serviceResult;
        }
        serviceResult.setPagerInfo(requestObject.getPagerInfo());
        serviceResult.setResult(masterDataSystemDtos);
        return serviceResult;

    }

//    @POST
//    @Path("supplier")
//    @ApiOperation(value = "供应商信息查询", notes = "供应商信息查询")
//    @Override
//    public ServiceResult<MasterDataSystemDto> getSupplierInformationBySelect(SupplierInformationReq requestObject) {
//        ServiceResult<MasterDataSystemDto> serviceResult = new ServiceResult<>();
//        MasterDataSystemDto masterDataSystemDto = null;
//        try {
//            masterDataSystemDto = masterDataSystemModel.getSupplierInformation(requestObject);
//        } catch (BusinessException be) {
//            serviceResult.setError(be.getCode(), be.getMessage());
//            return serviceResult;
//        } catch (Exception e) {
//            // 获取当前方法名
//            IfpLogger.error(Thread.currentThread().getStackTrace()[1].getMethodName(), "case: {}",
//                    Throwables.getStackTraceAsString(e));
//            serviceResult.setError(ErrorMessageConstant.ECUC0000_CODE, ErrorMessageConstant.ECUC0000_MESSAGE);
//            return serviceResult;
//        }
//        serviceResult.setResult(masterDataSystemDto);
//        return serviceResult;
//    }


}
